﻿using System;
using NUnit.Framework;

namespace IrishSettings.IntegrationTests.SettingsValuesTests
{
    [TestFixture]
    public class SettingsVaryByUser
    {

        //Depends on Reset
        [SetUp]
        public void SetUpFixture()
        {
            IrishSettingsManager hsm = new IrishSettingsManager(SchemaUtils.CreateSampleSchema());
            hsm.Reset();
        }

        [Test]
        public void GetCurrentVersionExpecingV1()
        {
            //Defaults
            IrishSettingsManager hsm = new IrishSettingsManager(SchemaUtils.CreateSampleSchema());

            AuthUtils.AuthByName("testerJoe");
            //Make sure nothing else is there.
            hsm.Reset();
            //hsm.Reset(new Version(1, 0));
            //hsm.Reset(new Version(2, 1));
            //Save or we won't get anything.
            hsm.Save();
            Assert.AreEqual("en-US", hsm["culture"].Value.ToString());
            Assert.AreEqual(new Version(1, 0).ToString(), hsm.VersionCurrent().ToString());
        }

        //[Test]
        //public void GetCurrentAndLastAfterUpdgrade()
        //{
        //    //Defaults
        //    IrishSettingsManager hsm = new IrishSettingsManager(SchemaUtils.CreateSampleSchema());
        //    AuthUtils.AuthByName("testerJoe");
        //    //Make sure nothing else is there.
        //    hsm.Reset();
        //    hsm.Reset(new Version(1, 0));
        //    hsm.Reset(new Version(2, 1));

        //    //Save forces, v1 to save
        //    hsm.Save();
        //    hsm.Upgrade(new Version(2, 1));
        //    //Save, now v2 has saved.
        //    hsm.Save();
        //    Assert.AreEqual("en-US", hsm["culture"].Value.ToString());
        //    Assert.AreEqual(new Version(2, 1).ToString(), hsm.VersionCurrent().ToString());
        //    Assert.AreEqual(new Version(1, 0).ToString(), hsm.VersionPrevious().ToString());
        //}


    }
}
